/*
 * DbPoolLock.cpp
 *
 *  Created on: 2020年4月5日
 *      Author: chuanjiang.zh
 */

#include "DbPoolLock.h"
#include "DbConnectionPool.h"


namespace db
{

DbPoolLock::DbPoolLock(DbConnectionPool* pool):
    m_locked(false),
    m_pool(pool)
{
    if (m_pool && m_pool->isSqlite())
    {
        m_pool->getLock().lock();
        m_locked = true;
    }
}

DbPoolLock::~DbPoolLock()
{
    unlock();
}

void DbPoolLock::unlock()
{
    if (m_pool && m_locked)
    {
        m_pool->getLock().unlock();
        m_locked = false;
    }
}


} /* namespace db */
